import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { GTextFormat } from "../../../common/GTextFormat";
import { LockInfoData } from "./LockInfoData";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { MsgManager } from "../../manager/MsgManager";
import { ELockStatus } from "../../../../Message/Game/ELockStatus";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GTextInput } from "../../../../com/mui/controls/GTextInput";
//class ConfirmProtectInfoSprite
    
    export  class ConfirmProtectInfoSprite /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc6=null;
            var loc7=null;
            var loc1=ObjCreate.createBg(10, 255, 280, 2, this, ImagesConst.SplitLine);
            var loc2=ObjCreate.createTextField("", 10, 10, 50, 20, this);
            loc2.htmlText = "<font size=\'12\' color=\'#f1ffb1\'>问题一：</font>";
            loc2.filters = [];
            var loc3=ObjCreate.createTextField("", 10, 130, 50, 20, this);
            loc3.htmlText = "<font size=\'12\' color=\'#f1ffb1\'>问题二：</font>";
            loc3.filters = [];
            this._ques1Txt = ObjCreate.createTextField("", 70, 30, 200, 20, this);
            this._ques1Txt.filters = [];
            this._ques2Txt = ObjCreate.createTextField("", 70, 150, 200, 20, this);
            this._ques2Txt.filters = [];
            var loc4;
            (loc4 = ObjCreate.createTextField("", 10, 70, 200, 20, this)).htmlText = "<font size=\'12\' color=\'#f1ffb1\'>答案一：</font>";
            loc4.filters = [];
            var loc5;
            (loc5 = ObjCreate.createTextField("", 10, 190, 200, 20, this)).htmlText = "<font size=\'12\' color=\'#f1ffb1\'>答案二：</font>";
            loc5.filters = [];
            this._answer1Txt = ObjCreate.createGTextInput(70, 90, 200, 25, this);
            this._answer2Txt = ObjCreate.createGTextInput(70, 210, 200, 25, this);
            loc6 = "以上是您设置的密保，请准确做出回答，以便进行确认。";
            (loc7 = ObjCreate.createTextField("", 10, 270, 280, 50, this)).defaultTextFormat = new GTextFormat("", 12, 11661311, null, null, null, null, null, null, null, null, null, 5);
            loc7.filters = [];
            loc7.wordWrap = true;
            loc7.multiline = true;
            loc7.htmlText = "<font size=\'12\' color=\'#b1efff\'>" + loc6 + "</font>";
            return;
        }

        public setQuestion(): void
        {
            this._ques1Txt.text = LockInfoData.questionOne;
            this._ques1Txt.setTextFormat(GlobalStyle.textFormat1);
            this._ques2Txt.text = LockInfoData.questionTwo;
            this._ques2Txt.setTextFormat(GlobalStyle.textFormat1);
            return;
        }

        public confirmProtectInfo(): void
        {
            if (this._answer1Txt.text == "" || this._answer2Txt.text == "") 
            {
                MsgManager.showRollTipsMsg("请填写你的密保答案");
            }
            else if (this._answer1Txt.text == LockInfoData.answerOne) 
            {
                if (this._answer2Txt.text == LockInfoData.answerTwo) 
                {
                    if (LockInfoData.lockStatus.value() == ELockStatus._ELockStatusNULL) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.LockToActive));
                    }
                }
                else 
                {
                    MsgManager.showRollTipsMsg("第二个密保答案与您设置的答案不一致");
                }
            }
            else 
            {
                MsgManager.showRollTipsMsg("第一个密保答案与您设置的答案不一致");
            }
            return;
        }

        public setPassWord(): void
        {
            if (this._answer1Txt.text == "" || this._answer2Txt.text == "") 
            {
                MsgManager.showRollTipsMsg("请填写你的密保答案");
            }
            else if (LockInfoData.lockStatus.value() == ELockStatus._ELockStatusNoPassword) 
            {
                LockInfoData.answerOne = this._answer1Txt.text;
                LockInfoData.answerTwo = this._answer2Txt.text;
                Dispatcher.dispatchEvent(new DataEvent(EventName.LockToActive));
            }
            return;
        }

        public answerQuestion(): void
        {
            var loc1=null;
            if (this._answer1Txt.text == "" || this._answer2Txt.text == "") 
            {
                MsgManager.showRollTipsMsg("请填写你的密保答案");
            }
            else if (LockInfoData.lockStatus.value() == ELockStatus._ELockStatusLocked || LockInfoData.lockStatus.value() == ELockStatus._ELockStatusUnLocked) 
            {
                loc1 = [];
                LockInfoData.answerOne = this._answer1Txt.text;
                LockInfoData.answerTwo = this._answer2Txt.text;
                loc1.push(this._answer1Txt.text);
                loc1.push(this._answer2Txt.text);
                Dispatcher.dispatchEvent(new DataEvent(EventName.LockAnswerQuestions, loc1));
            }
            return;
        }

        public clearLock(): void
        {
            var loc1=null;
            if (this._answer1Txt.text == "" || this._answer2Txt.text == "") 
            {
                MsgManager.showRollTipsMsg("请填写你的密保答案");
            }
            else if (LockInfoData.lockStatus.value() == ELockStatus._ELockStatusLocked || LockInfoData.lockStatus.value() == ELockStatus._ELockStatusUnLocked) 
            {
                loc1 = [];
                LockInfoData.answerOne = this._answer1Txt.text;
                LockInfoData.answerTwo = this._answer2Txt.text;
                loc1.push(this._answer1Txt.text);
                loc1.push(this._answer2Txt.text);
                Dispatcher.dispatchEvent(new DataEvent(EventName.LockClearPassword, loc1));
            }
            return;
        }

        public resetSprite(): void
        {
            this._answer1Txt.text = "";
            this._answer2Txt.text = "";
            return;
        }

        /* internal */ /* var */_ques1Txt: Object /* flash.text.TextField */;

        /* internal */ /* var */_ques2Txt: Object /* flash.text.TextField */;

        /* internal */ /* var */_answer1Txt: GTextInput;

        /* internal */ /* var */_answer2Txt: GTextInput;
    }
